﻿using System;
using System.Collections;
using System.Text;
using Peekaboo2008.model;
using System.Data;
using Peekaboo2008.util;
using System.Data.SqlClient;

namespace Peekaboo2008.dao
{
    class ReportDAO
    {
        public static DataTable HangBanTrongKhoangNgayTheoNhanVien(String _chiNhanh, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[3];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangBanTrongKhoangNgayTheoNhanVien", param);            
        }

        public static DataTable HangBanTrongKhoangNgayTheoNhomHang(String _chiNhanh, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[3];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangBanTrongKhoangNgayTheoNhomHang", param);
        }

        public static DataTable ChiTietHangHoaBanRa(String _chiNhanh, String _ngayXem)
        {
            SqlParameter[] param = new SqlParameter[2];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ngay_xem", SqlDbType.NVarChar);
            param[i++].Value = _ngayXem;
            return DataUtil.executeStore("sp_Report_ChiTietHangHoaBanRa", param);
        }
        
        public static DataTable BanHangVaThuTienTheoNgay(String _chiNhanh, String _ngayXem)
        {
            SqlParameter[] param = new SqlParameter[2];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ngay_xem", SqlDbType.NVarChar);
            param[i++].Value = _ngayXem;
            return DataUtil.executeStore("sp_Report_BanHangVaThuTienTheoNgay", param);
        }

        public static DataTable TongHopThuChiTheoNgay(String _chiNhanh, String _ngayXem)
        {
            SqlParameter[] param = new SqlParameter[2];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ngay_xem", SqlDbType.NVarChar);
            param[i++].Value = _ngayXem;
            return DataUtil.executeStore("sp_Report_TongHopThuChiTheoNgay", param);
        }

        public static DataTable LoiNhuanHoaDon(String MaPhieu)
        {
            SqlParameter[] param = new SqlParameter[1];
            int i = 0;
            param[i] = new SqlParameter("@Ma_phieu_nhap_xuat", SqlDbType.NVarChar);
            param[i++].Value = MaPhieu;

            return DataUtil.executeStore("sp_ReportLoiNhuan_LoiNhuanHoaDon", param);
        }

        public static DataTable HangTonTheoTungNhomHang(String _chiNhanh, String _nhomHang, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[4];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ma_nhom_hang", SqlDbType.NVarChar);
            param[i++].Value = _nhomHang;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangTonTheoTungNhomHang", param);
        }

        public static DataTable HangTonTheoTatCaNhomHang(String _chiNhanh, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[3];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangTonTheoTatCaNhomHang", param);
        }

        public static DataTable HangTonTheoTungNganhHang(String _chiNhanh, String _nganhHang, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[4];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ma_nganh_hang", SqlDbType.NVarChar);
            param[i++].Value = _nganhHang;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangTonTheoTungNganhHang", param);
        }

        public static DataTable HangTonTheoTatCaNganhHang(String _chiNhanh, String _tuNgay, String _denNgay)
        {
            SqlParameter[] param = new SqlParameter[3];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Tu_ngay", SqlDbType.NVarChar);
            param[i++].Value = _tuNgay;
            param[i] = new SqlParameter("Den_ngay", SqlDbType.NVarChar);
            param[i++].Value = _denNgay;
            return DataUtil.executeStore("sp_Report_HangTonTheoTatCaNganhHang", param);
        }

        public static DataTable HangTonDuoiDinhMuc(String _chiNhanh, String _ngayXem)
        {
            SqlParameter[] param = new SqlParameter[2];
            int i = 0;
            param[i] = new SqlParameter("Ma_chi_nhanh", SqlDbType.NVarChar);
            param[i++].Value = _chiNhanh;
            param[i] = new SqlParameter("Ngay_xem", SqlDbType.NVarChar);
            param[i++].Value = _ngayXem;
            return DataUtil.executeStore("sp_Report_HangTonDuoiDinhMuc", param);
        }

    }
}
